$(document).ready(function(){
	
	/*投资列表页*/
	$(document).on("pageInit", "#News", function(e, id, page) {
		
		var w = 0;
		$('#nav-tabs li').each(function(){
			w += $(this).outerWidth();
		});
		$('#nav-tabs #scroller').css({"width":w+10});
		
		var now_page = 1;
		var all_page = 0;
		var loading = false;
		$("#news .infinite-scroll-preloader").hide();
		$(page).on('infinite', function() {
			all_page=$("#news .content .J_page_total").val();
			now_page = $("#news .content").attr("now_page");
			now_page = parseInt(now_page);
		   	if (loading || now_page >= all_page) return;
			$("#news .infinite-scroll-preloader").show();
		    loading = true;
			var query = newObject();
			query.page  =  now_page + 1;
			query.is_ajax = 1;
			
			var parms = get_search_parms();
			var ajaxurl = $("#news .infinite-scroll").attr("ajaxurl");
		    $.ajax({
		      	url:ajaxurl + parms,
		        data:query,
		        success:function(result){
		        	now_page ++;
					$("#news .content").attr("now_page",now_page);
		        	loading = false;
					$("#news .content .J_page_total").remove();
		        	$("#news .infinite-scroll .news-list ul").append(result);
		        	$("#news .infinite-scroll .pull-to-refresh-layer").last().remove();
		        	$("#news .infinite-scroll-preloader").hide();
		        	$.refreshScroller();
		        }
		      });
	       
	    });
	    
	    var $content = $(page).find(".content").on('refresh', function(e) {
	    	
	      	if (loading) return;
	      	loading =true;
	      	var query = newObject();
			query.page  =  1;
			query.is_ajax = 1;
			var parms = get_search_parms();
			var ajaxurl = $("#news .infinite-scroll").attr("ajaxurl");
		    $.ajax({
		    	url:ajaxurl + parms,
		        data:query,
		        success:function(result){
		        	now_page=1;
					 $("#news .content").attr("now_page",now_page);
		        	loading =false;
		       	 	$content.find('.news-list ul').html(result);
		       	 	$("#news .infinite-scroll").attr("all_page",$("#news .pull-to-refresh-layer").attr("all_page"));
	       			$.pullToRefreshDone($content);
		       	}
		     });
	    });
	  });
	  
 });
	

